/***********************************************************
 * Product Name: ExcelQuicker
 * Copyright (c)2005, Eunge
 * Author: Eunge
 * Web Site: www.eudev.net
 * Mail/MSN: eudev.net@yeah.net
 * ********************************************************/
using System;
using System.Collections;
using System.Collections.Specialized;

namespace ExcelQuicker.Framework
{
	/// <summary>
	/// The collection of EQObject objects
	/// </summary>
	[Serializable]
	abstract public class EQCollection: CollectionBase
	{
		/// <summary>
		/// Add a new EQObject object
		/// </summary>
		/// <param name="objEQObject"></param>
		public void Add(EQObject objEQObject)
		{
			this.List.Add(objEQObject);
		}

		/// <summary>
		/// Remove a EQObject object
		/// </summary>
		/// <param name="objEQObject"></param>
		public void Remove(EQObject objEQObject)
		{
			this.List.Remove(objEQObject);
		}

		/// <summary>
		/// Insert a new EQObject object at specialized position
		/// </summary>
		/// <param name="index"></param>
		/// <param name="objEQObject"></param>
		public void Insert(int index, EQObject objEQObject)
		{
			this.List.Insert(index, objEQObject);
		}

		/// <summary>
		/// Return the index of objEQObject in current collection
		/// </summary>
		/// <param name="objEQObject"></param>
		/// <returns></returns>
		public int IndexOf(EQObject objEQObject)
		{
			return this.List.IndexOf(objEQObject);
		}

		/// <summary>
		/// Check the current collection whether contains the objEQObject
		/// </summary>
		/// <param name="objEQObject"></param>
		/// <returns></returns>
		public bool Contains(EQObject objEQObject)
		{
			return this.List.Contains(objEQObject);
		}

		/// <summary>
		/// Set/Get EQObject object by setting index
		/// </summary>
		public EQObject this[int index]
		{
			get
			{
				return this.List[index] as EQObject;
			}
			set
			{
				this.List[index] = value;
			}
		}

		/// <summary>
		/// Copy the object which its index more from index to objEQCollection
		/// </summary>
		/// <param name="objEQCollection"></param>
		/// <param name="index"></param>
		public void CopyTo(EQCollection objEQCollection, int index)
		{
			if(index >= this.List.Count)
				throw new EQException("EQ1002", this.GetType().ToString(), index.ToString(EQKit.ObjNumberFormatInfo), this.List.Count.ToString(EQKit.ObjNumberFormatInfo));
			int i = index;
			while(i < this.List.Count)
			{
				objEQCollection.Add(this.List[i] as EQObject);
			}
		}
	}
}
